#lang sicp

;; require `Exercise-1.21.rkt`

(define (timed-prime-test n)
  (start-prime-test n (runtime)))

(define (start-prime-test n start-time)
  (if (prime? n)
      (report-prime n (- (runtime) start-time))))

(define (report-prime n elapsed-time)
  (display n)
  (display " *** ")
  (display elapsed-time)
  (newline))

(define (search-for-primes l r)
  (cond ((> l r) nil)
        ((even? l) (search-for-primes (+ l 1) r))
        (else (timed-prime-test l)
              (search-for-primes (+ l 2) r))))


;; (search-for-primes 1e8 (+ 1e8 1000))
;; (search-for-primes 1e9 (+ 1e9 1000))
;; 观察结果大约是 2 ~ 3 倍，考虑到一些误差差不多也是可以认为是 sqrt(10) 了